// Kony

#pragma once

#include "CoreMinimal.h"
#include "BaseAbilityTypes.h"
#include "BaseGameplayTags.h"
#include "AbilitySystem/Abilitys/BaseGameplayAbility.h"
#include "BaseDamageGameplayAbility.generated.h"


/**
 * 游戏能力伤害类 用于扩展伤害的游戏能力子类
 */
UCLASS()
class GASC_HUANLING_API UBaseDamageGameplayAbility : public UBaseGameplayAbility
{
	GENERATED_BODY()
public:
	//定义可重写 能力描述函数 用于各技能编写能力描述
	virtual FString GetDescription(int32 Level, const FText& Title, const FText& Description);
	//定义可重写 下一级能力描述函数 用于各技能下一级编写能力描述
	virtual FString GetNextLevelDescription(int32 Level, const FText& Title, const FText& Description);
	//使用游戏标签Tag，伤害触发函数
	UFUNCTION(BlueprintCallable)
	void CauseDamage(AActor* TargetActor);
	/**
	 * 根据类的默认设置创建伤害效果参数结构体
	 * @param TargetActor 可选的目标Actor，用于应用伤害效果
	 * @return 包含伤害配置信息的FDamageEffectParams结构体
	 */
	UFUNCTION(BlueprintPure)
	FDamageEffectParams MakeDamageEffectParamsFromClassDefaults(
		AActor* TargetActor = nullptr,
		FVector InRadialDamageOrigin = FVector::ZeroVector,
		bool bOverrideKnockbackDirection = false, //是否覆盖击退方向
		FVector InKnockbackDirectionOverride = FVector::ZeroVector, //覆盖击退方向
		bool bOverrideDeathImpulse = false, //是否覆盖死亡击退方向
		FVector InDeathImpulseDirectionOverride = FVector::ZeroVector,//覆盖死亡击方向
		bool bOverridePitch = false, //是否覆盖冲击方向
		float PitchOverride = 0.f //覆盖冲击方向 俯仰角
		) const;

	//获取对应级别伤害
	UFUNCTION(BlueprintPure)
	float GetDamageAtLevel() const;
	
private:
	UPROPERTY()
	int32 MontageIndex = 0;
protected:
	//伤害效果类变量
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
	TSubclassOf<UGameplayEffect> DamageEffectClass;
	//通过游戏标签 设置伤害类型,这个是一个伤害类型map 可以传递多种，看情况选择用多种还是一种，这两种可以同时存在，但只能使用一种
	// UPROPERTY(EditDefaultsOnly , Category = "Damage")
	// TMap<FGameplayTag, FScalableFloat> DamageTypes;
	//下面这俩是指定伤害类型
	//伤害类型
	UPROPERTY(EditDefaultsOnly, Category = "Damage", Meta = (Categories = "Damage"))
	FGameplayTag DamageType;
	//伤害数值
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	FScalableFloat Damage;

	//异常属性类型
	UPROPERTY(EditDefaultsOnly, Category = "Damage", Meta = (Categories = "Debuff"))
	FGameplayTag DebuffType = FBaseGameplayTags::Get().Debuff_Propertie_None;
	//异常状态触发概率
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float DebuffChance = 12.f;
	//异常伤害-如果类型为固定 则直接使用伤害数值，如果为百分比，就用伤害数值去乘技能伤害数值
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float DebuffDamage = 1.f;
	//是否启用异常伤害 如果启用就按照伤害的百分比计算
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	bool DebuffDamagePercentage = false;
	//异常值数组 非伤害类型的异常比例值，比如减速、易伤、破甲等 可设置多种
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	TArray<float> DebuffValue = {0.f};
	//异常伤害每跳频率
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float DebuffFrequency = 1.f;
	//异常状态持续时间
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float DebuffDuration = 5.f;
	//击杀敌人死亡时冲击量大小，也就是这个技能在击杀敌人时造成的冲击量 可以把怪物尸体击飞
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float DeathImpulseMagnitude = 500.f;
	//击退力度
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float KnockbackForceMagnitude = 1000.f;
	//击退几率
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float KnockbackChance = 0.f;
	//硬直值
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	float Stagger = 35.0f;
	//是否径向衰减伤害(也就是距离中心越远伤害越低)
	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	bool bIsRadialDamage = false;
	//径向内半径
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Damage")
	float RadialDamageInnerRadius = 0.f;
	//径向外半径
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Damage")
	float RadialDamageOuterRadius = 0.f;
	
	//从传入的蒙太奇数组中 随机获取一个蒙太奇（主要用于随机攻击动画）,或者 按顺序指定返回
	UFUNCTION(BlueprintPure)
	FTaggedMontage GetRandomTaggedMontageFromArray(const TArray<FTaggedMontage>& TaggedMontages,const bool bUseSequential);
	//通过伤害类型，获取伤害值
	float GetDamageByDamageType(float InLevel, const FGameplayTag& DamageType);
};
